﻿using UnityEngine;
using System.Collections;

public class TayController : MonoBehaviour {

	// Use this for initialization
    public Vector3 currentVector;
    public bool isVa =  false;
    public GameObject chu;
	void Start ()
	{
	    currentVector = transform.position;
        Debug.Log("co vao day k");
	    Debug.Log(currentVector);
	}
	
	// Update is called once per frame
	void Update () {
	    if (isVa)
	    {
            this.gameObject.transform.position = Vector3.Lerp(this.gameObject.transform.position, chu.transform.position, Time.deltaTime * 2);
            Debug.Log("dung dm" + gameObject.name);
            chu.transform.position = Vector3.MoveTowards(chu.transform.position, currentVector, Time.deltaTime * 2);   
	    }
	}
     void OnTriggerEnter2D(Collider2D coll) 
     {
        Debug.Log("va cham"+coll.gameObject.name);
         isVa = true;
         chu = coll.gameObject;
     }
}
